package com.hns.phone.energy.web;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hns.can.base.entity.SysUserEntity;
import com.hns.can.common.domain.GridPage;
import com.hns.can.common.web.BaseController;
import com.hns.frame.mybatis.Pagination;
import com.hns.phone.energy.service.PhoneDriverEnergyService;
import com.hns.phone.energy.vo.DriverEnergyRankVo;
import com.hns.phone.energy.vo.NewEnergy;
import com.hns.tool.pub.PubUtil;

@Controller
@RequestMapping("/api/phoneDriverEnergy")
public class PhoneDriverEnergyController extends BaseController {
	
	@Autowired
	private PhoneDriverEnergyService phoneDriverEnergyService;
	
	@SuppressWarnings("serial")
	private Map<String, String> map = new HashMap<String, String>(){
		{
			put("oil", "单车百公里油耗趋势");
			put("elec", "单车百公里电耗趋势");
			put("gas", "单车百公里气耗趋势");
		}
	};
	
	@SuppressWarnings("serial")
	private Map<String, String> rankMap = new HashMap<String, String>(){
		{
			put("oil", "'1', '2'");
			put("elec", "'3'");
			put("gas", "'4', '5'");
		}
	};
//	
//	/**
//	 * 驾驶员能耗排名
//	 * @param vo
//	 * @return
//	 * @throws Exception
//	 * @author:zhangyu
//	 * @email:zhangyu2222z@sina.cn
//	 */
//	@RequestMapping("/getDriverEnergyRanking")
//	@ResponseBody
//	public Object getDriverEnergyRanking(NewEnergy vo) throws Exception {
//		SysUserEntity user = this.getPhoneCurrentUser();
//        vo.setCorpId(user.getCorpId());
//        String enerType = vo.getEnerType();
//        String fuelType = rankMap.get(enerType);
//        vo.setFuelTypeCode(fuelType);
//        Pagination page = phoneDriverEnergyService.getDriverEnergyRanking(vo);
//        GridPage grid = new GridPage(page);
//        return this.getReturnResult(grid);
//	}
	
	
	/**
	 * 驾驶员能耗排名（前五）
	 * @param vo
	 * @return
	 * @throws Exception
	 * @author:zhangyu
	 * @email:zhangyu2222z@sina.cn
	 */
	@RequestMapping("/getDriverEnergyRankingForFive")
	@ResponseBody
	public Object getDriverEnergyRankingForFive(NewEnergy vo) throws Exception {
		if(vo.getEnerType().equals("gas")){
			vo.setEnerType("030702");
		}else if(vo.getEnerType().equals("elec")){
			vo.setEnerType("030602");
		}else if(vo.getEnerType().equals("oil")){
			vo.setEnerType("030502");
		}
		SysUserEntity user = this.getPhoneCurrentUser();
		vo.setUserId(user.getId());
		List<DriverEnergyRankVo> list = phoneDriverEnergyService.getDriverEnergyRankingForFive(vo);
		return this.getReturnResult(list);
	}
}
